<template>
  <div>
    {{smallModelProbability}}
  </div>
</template>

<script setup lang="ts">
import { ref, defineProps, } from "vue";
const props = defineProps({
  probabilityTexts: {
    type: String,
    required: true,
    default: "",
  },
});
let probabilityTimer;
let smallModelProbability = ref<string>("");

const displayProbabilityByOne = () => {
 if (!props.probabilityTexts) {
    clearInterval(probabilityTimer);
 }
  let curIndex:number = 0;
  probabilityTimer = setInterval(() => {
    //先清空
    smallModelProbability.value = "";

    smallModelProbability.value = props.probabilityTexts.substr(0, curIndex);
    if (curIndex < props.probabilityTexts.length) {
      curIndex++;
    } else {
      clearInterval(probabilityTimer);
    }
  }, 100); //100是时间间隔
};
displayProbabilityByOne();
</script>

<style scoped>
div{
  font-size: 20px;
}
</style>